<script type="text/html" template>
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/home/info.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/page.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/patrol/project_device_alert.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/dtree.css">
</script>
<style scoped>
    .leon-style-alert .con2 input {
    display: inline-block;
    width: 70px;
    height: 20px;
    margin-right: 0px;
    border: 1px solid #F7F7F7;
    padding-left: 0px;
}
.footer{
   margin-top: 22px;
}
.dtree-select-show{
  min-width: 250px;
  height: 250px !important;
}
.dtree-select .edgeI{
  display: none;
}
.mode {
border-radius: 6px;
padding: 10px 15px;
background: #1E9FFF;
color: #fff;
margin-right: 4px;
margin-bottom: 4px;
position: relative;
display: inline-block;
}

.mode .deleteMode {
position: absolute;
right: 2px;
top: 2px;
font-size: 12px;
cursor: pointer;
}

#typeTree_tree {
width: auto;
}

.InputButton {
background: #CCDAE3;
margin-bottom: 15px;
color: #666;
}
.Imagetages {
    left: -9px;
    top: 499px;
}
#myselect .layui-select-title{
  position: relative;
    left: -43px;
}
#myselect .layui-edge{
  right: -30px;
}
.Falges{
  color:red;
  font-size: 18px;
  position: absolute;
  top: 13px;
  left: -8px;
  display: none;
}
</style>
<!-- 标题 -->
<div class="layui-fluid">
<div class="layui-row">
<div class="InfoTitle layim-title" data-lang="FillInTheEquipmentDetails">
  设备详细信息填写
</div>
<!-- 设备信息录入 -->
<button class="InputButton layui-btn layui-btn-xs layui-btn-radius"><i
    class="layui-icon layui-icon-add-circle-fine"></i>设备信息录入</button>
</div>
</div>
<!-- 建立视图。用于呈现渲染结果。 -->
<div class="layui-fluid">
<div class="layui-form" class="TaoYong" id="testDiv" lay-filter="dataForm" style="background:#fff;padding: 10px;">
</div>
</div>


<!-- 模板引擎 (自己的模板)-->
<script id="template" type="text/html">
<!-- layui-form -->
<div class="layui-form FormData layui-row" lay-filter="dataForm" id="dataForm">

<!-- 第一列 -->
<div class="layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="llp layui-form-item layui-form">
  <label class="layui-form-label" data-lang="equipmentNumber">设备编号:</label>
  <div class="layui-input-block">
    <input type="text" name="fia01" required lay-verify="" autocomplete="off" class="layui-input DataNone"
      value="{{ d.tcApplyFia01 }}">
    <!-- {{ d.tcApplyFia01 }} -->
     {{#  if(d.tcApplyFia01 == null || d.tcApplyFia01==undefined){ }}
         
     {{#  } else { }}
         {{ d.tcApplyFia01}}
     {{#  } }}
  </div>
</div>

<!-- 带 -->
<div class="layui-form-item">
  <label class="layui-form-label" data-lang="accountSet"><i class="Tagred">*</i>公司名称：</label>
  <div class="layui-input-block" style="line-height: 36px;">
    <select name="fiaplant" lay-verify="required" lay-filter='select' lay-search id="zhangTao">
      <option value=""></option>

    </select>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="AssetsEncoding"><i class="Tagred">*</i>资产编码:</label>
  <div class="layui-input-block">
    <input type="text" name="fia011" required lay-verify="required" placeholder="" autocomplete="off"
      class="layui-input" id="CodeMa">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="devicename"><i class="Tagred">*</i>设备名称:</label>
  <div class="layui-input-block">
    <input type="text" name="fia02" required lay-verify="required" placeholder="" autocomplete="off"
      class="layui-input">
  </div>
</div>
<!-- 设备停用启用 -->
<div class="layui-form-item">
  <label class="layui-form-label" data-lang="devicename"><i class="Tagred">*</i>设备停用启用:</label>
  <div class="layui-input-block">
     <input type="radio" data-lang="yes" name="tcDevIsDisable" value="0" title="启用" checked>
     <input type="radio" data-lang="no" name="tcDevIsDisable" value="1" title="停用">
  </div>
</div>
<!-- 需要带过来 -->
<div class="llp layui-form-item layui-form">
  <label class="layui-form-label" data-lang="deviceType"><i class="Tagred">*</i>设备类型：</label>
  <div class="layui-input-block" style="width: 158px;">
    <input type="text" name="" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input"
      id="typeTree" style="cursor:pointer">
    <input type="text" name="fia03" required lay-verify="" placeholder="" autocomplete="off" class="layui-input"
      id="typeTreeTwo" style="display:none;">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="StartDate">启动日期:</label>
  <div class="layui-input-block">
    <input type="text" name="fia19" required lay-verify="" id="qiDongDay" autocomplete="off" class="layui-input"
      style="cursor:pointer;">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="warrantyDate">保修日期:</label>
  <div class="layui-input-block">
    <input type="text" name="fia20" required lay-verify="" placeholder="" autocomplete="off" class="layui-input"
      id="fixData" style="cursor:pointer;">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label"><span data-lang="acceptanceDate">验收日期</span>:</label>
  <div class="layui-input-block">
    <input type="text" name="tcDevChkdate" required id="YanShouData" autocomplete="off" class="layui-input"
      style="cursor:pointer;">
  </div>
</div>

<!-- 带(数组) -->
<div class="layui-form-item PiceTrue">
  <div class="textPc" style="float:left"><i class="Imagetages">*</i><span data-lang="EquipmentPictures">设备图片</span>：
  </div>
  <input type="text" name="tcFilePath" id="id_upload" lay-verify="required" class="uploadeImag" value="上传图片"
    style="cursor: pointer;">
  <input type="text" name="tcFilePath" class="dataElement" value="" style="display:none;">
  <!-- 图片预览放大功能 -->
  <!--图片预览 -->
  <div class="photograph" style="position:relative;overflow:hidden;padding:4px;">
    <ul id="path" style='display:flex;flex-wrap:wrap;box-sizing:border-box;overflow:hidden;'></ul>
  </div>
</div>
<!-- 停用和启用 -->

</div>
<!-- 第二列 -->
<div class="layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
<!-- 页面带过了 -->
<div class="llp layui-form-item layui-form">
  <label class="layui-form-label" data-lang="unitType">设备型号:</label>
  <div class="layui-input-block">
    <input type="text" name="fia05" required lay-verify="" autocomplete="off" class="layui-input DataNone"
      value="{{d.fii02}}">
    {{#  if(d.fii02 == null || d.fii02==undefined){ }}
         
     {{#  } else { }}
         {{ d.fii02}}
     {{#  } }}
  </div>
</div>


<!-- 页面带过来 -->
<div class="llp layui-form-item layui-form">
  <label class="layui-form-label" data-lang="DEVSeries">设备系列：</label>
  <div class="layui-input-block">
    <input type="number" name="fia04" required autocomplete="off" class="layui-input DataNone"
      value="{{d.tcSeriesCode}}">
    <!-- {{d.tcSeriesName}} -->
    {{#  if(d.tcSeriesName == null || d.tcSeriesName==undefined){ }}
         
     {{#  } else { }}
         {{ d.tcSeriesName}}
     {{#  } }}
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="DEVStatus">设备状态</span>：</label>
  <div class="layui-input-block">
    <select name="fiaacti" lay-search lay-verify="required">
      <option></option>
      <option value="0">一般</option>
      <option value="1">良好</option>
      <option value="2">不稳定</option>
      <option value="3">折旧中</option>
      <option value="4">外送</option>
      <option value="5">折毕</option>
      <option value="6">出售</option>
      <option value="7">报废</option>
      <option value="8">折毕再提</option>
      <option value="9">改良</option>
      <option value="A">重估</option>
    </select>
  </div>
</div>

<div class="llp layui-form-item layui-form">
  <label class="layui-form-label" data-lang="supplier">供应商：</label>
  <div class="layui-input-block">
    <input type="text" name="fia09" required lay-verify="" autocomplete="off" class="layui-input DataNone"
      value="{{d.pmc01}}">
     {{#  if(d.pmc03 == null || d.pmc03==undefined){ }}  
     {{#  } else { }}
         {{ d.pmc03}}
     {{#  } }}
  </div>
</div>

<!-- 带 -->

<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span
      data-lang="responsibleDepartment">负责部门</span>:</label>
  <div class="layui-input-block" style="width:156px;line-height: 45px;" id="myselect">
    <div id="treeSelect" class="dtree" data-id="0" style="width:100%;display:block;" data-value="001"></div>
    <input type="text" id="treeSelect2" name="fia11" autocomplete="off" class="layui-input" style="display:none;">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="custodian">保管人</span>:</label>
  <div class="layui-input-block">
    <!-- 保管人字段 -->
    <select name="fia10" lay-search id="selectPerone" lay-verify="required">
      <option value=""></option>

    </select>
  </div>
</div>

<!-- 带 (数组)-->
<!-- <div class="layui-form-item">
  <label class="layui-form-label" data-lang="MachineCapacity">机台能力:</label>
  <div class="layui-input-block">
    <div class="modeBox" id="detailBox"></div>
    <div id="alertChooseOne"><i class="layui-icon layui-icon-add-1" style="font-size: 25px; color: #1E9FFF;"></i>
    </div>
  </div>
</div> -->

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="accuracy">精度:</label>
  <div class="layui-input-block">
    <input type="text" name="tcDevPrecision" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input">
  </div>
</div>

<!--带数组-->
<!-- <div class="layui-form-item">
  <label class="layui-form-label">可生产产品类型:</label>
  <div class="ShanChanType layui-input-block">

    <div class="modeBox" id="typeBox"></div>
    <div id="alertChooseTwo"><i class="layui-icon layui-icon-add-1" style="font-size: 25px; color: #1E9FFF;"></i>
    </div>
  </div>
</div> -->

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="NormalProductionTime">正常生产时长:</label>
  <div class="layui-input-block">
    <input type="number" name="tcScadaProdtime" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input" id="timeFange" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="standbyTime">待机时长:</label>
  <div class="layui-input-block">
    <input type="number" name="tcScadaStdbytime" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input" id="daijiTime" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="abnormalTime">异常时长:</label>
  <div class="layui-input-block">
    <input type="number" name="tcScadaExcptime" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input" id="errorTime" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="safetyInstructions">安全说明</span>:</label>
  <div class="layui-input-block">
    <textarea name="fia25" required lay-verify="required" placeholder="" class="layui-textarea"
      id="anquanshuoming"></textarea>
  </div>
</div>

</div>

<!-- 第三个： -->
<div class="ThreeDivBan layui-form layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="layui-form-item" style="width: 110px;">
  <label class="layui-form-label" style="width:100px;"><i class="Tagred">*</i><span
      data-lang="EquipmentTuner">设备调机人员</span>：</label>
  <div class="SheBeiPonser layui-input-block">
    <select name="fiauser" lay-verify="required" id="ponser" lay-search>
      <option value=""></option>

    </select>
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="plant">厂房</span>：</label>
  <div class="layui-input-block">
    <select name="fia14" lay-search id="ChangFang" lay-filter='select2' lay-verify="required">
      <option value=""></option>
    </select>
  </div>
</div>


<!-- 楼层 -->
<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="floor">楼层</span>:</label>
  <div class="layui-input-block">
    <select name="fia15" lay-search lay-filter='' id="louCeng" lay-verify="required">
      <option value=""></option>
    </select>
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i><span data-lang="Station_process">站别/工序</span>：</label>
  <div class="layui-input-block">
    <select name="fia16" lay-search id="zhanBie" lay-verify="required">
      <option value=""></option>

    </select>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label"><i class="Tagred">*</i>线别：</label>
  <div class="layui-input-block">
    <select name="fia17" lay-search id="xianBie" lay-verify="required">
      <option value=""></option>

    </select>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="dateOfPurchase">购买日期:</label>
  <div class="layui-input-block">
    <input type="text" name="fia18" required placeholder="" autocomplete="off" class="layui-input" id="buyData"
      style="cursor:pointer;">
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="MaintenanceDuration">维修保养时长:</label>
  <div class="layui-input-block">
    <input type="number" name="tcScadaMainttime" placeholder="" autocomplete="off" class="layui-input"
      id="baoYangTime" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="output">产量:</label>
  <div class="layui-input-block">
    <input type="number" name="tcScadaProduction" required placeholder="" autocomplete="off" class="layui-input" disabled>
  </div>
</div>

<div class="layui-form-item" style="text-align: center;">
  <label class="layui-form-label" data-lang="Whetheronline">是否联机：</label>
  <div class="layui-input-inline" style="margin-left: 35px;">
    <input type="radio" data-lang="yes" lay-filter="tcScadaIsonineT" name="tcScadaIsonine" value="Y" title="是">
    <input type="radio" data-lang="no" lay-filter="tcScadaIsonineT" name="tcScadaIsonine" value="N" title="否" checked>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="Drivingtype"><i class="Falges">*</i>驱动类型:</label>
  <div class="layui-input-block">
    <input type="text" name="tcScadaDrvtype" required lay-verify="driveType" placeholder="" autocomplete="off"
      class="layui-input" id="driveType" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="Drivingname"><i class="Falges">*</i>驱动名称:</label>
  <div class="layui-input-block">
    <input type="text" name="tcScadaDrvname" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input" id="driveName" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="DeviceID"><i class="Falges">*</i>设备IP:</label>
  <div class="layui-input-block">
    <input type="text" name="tcScadaIpaddress" required lay-verify="" placeholder="" autocomplete="off"
      class="layui-input" id="facilityIp" disabled>
  </div>
</div>

<div class="layui-form-item">
  <label class="layui-form-label" data-lang="remark">备注:</label>
  <div class="layui-input-block">
    <textarea name="fia22" required placeholder="" class="layui-textarea" id="beiZhu"></textarea>
  </div>
</div>

</div>
<!-- 确定和取消按钮 -->
<div class="layui-fluid">
<div class="layui-col-md12">
  <div class="InfoButton">
    <button id="btnSubmit" lay-submit lay-filter="formSubmlitButton" data-lang="confirm">确定</button>
    <button class="cancel-btn" data-lang="cancel">取消</button>
  </div>
</div>
</div>
</div>
</script>
<!-- 机台能力 -->
<!-- <script type="text/html" id="addDeviceTpl">
  <style scoped>
    .leon-style-alert .layui-table-page,.layui-table-page .layui-laypage input{
            background-color:transparent;   
       }
       .leon-style-alert .layui-table-view {
         border-width: 1px;
         border-style: solid;
         border-color: #e6e6e6;
     }
 </style>
<div class="leon-style-alert">
  <div class="layui-alert-box">
    <div class="layui-alert-title">
      <span class="layui-title-inner">机台能力</span>
      <span class="layui-title-screen">
      </span>
    </div>
    <div class="layui-content">
      <div class="con1 toggle-btn">
        <span class="screen">
          <i class="query-icon  layui-icon"></i>
          <span class="query-inner">查询条件</span>
        </span>
        <i class="icon layui-icon layui-icon-down"></i>
      </div>
      <div class="con2 toggle-content">
        <form action="" class="layui-form">
          <label for="">机台能力编号:</label>
          <input type="text" name="id" />
          <label for="">机台能力名称:</label>
          <input type="text" name="name" />
          <label for="">机台能力描述:</label>
          <input type="text" name="dsc" />
          <button type="button" lay-submit lay-filter="queryTableDevice"
            class="query layui-btn layui-btn-radius layui-btn-primary">
            <span class="search-icon"></span>
            <span class="btn-inner">查询</span>
          </button>
        </form>
      </div>
      <table class="layui-table" id="MachineCapacityTable"></table>
    </div>
    <div class="footer layui-btn-containner">
      <button class="btn1 layui-btn layui-btn-radius layui-btn-primary">确定</button>
      <button class="btn2 layui-btn layui-btn-radius layui-btn-primary">取消</button>
    </div>
  </div>
</div>
</script> -->
<!-- 可生产产品类型 -->
<!-- <script type="text/html" id="addDeviceTpl2">
  <style scoped>
    .leon-style-alert .layui-table-page,.layui-table-page .layui-laypage input{
            background-color:transparent;   
       }
       .leon-style-alert .layui-table-view {
         border-width: 1px;
         border-style: solid;
         border-color: #e6e6e6;
     }
 </style>
<div class="leon-style-alert">
  <div class="layui-alert-box">
    <div class="layui-alert-title">
      <span class="layui-title-inner">可生产产品类型</span>
      <span class="layui-title-screen">
      </span>
    </div>
    <div class="layui-content">
      <div class="con1 toggle-btn">
        <span class="screen">
          <i class="query-icon  layui-icon"></i>
          <span class="query-inner">查询条件</span>
        </span>
        <i class="icon layui-icon layui-icon-down"></i>
      </div>
      <div class="con2 toggle-content">
        <form action="" class="layui-form">
          <label for="">产品类型编号:</label>
          <input type="text" name="id" />
          <label for="">产品类型名称:</label>
          <input type="text" name="name" />
          <label for="">产品类型描述:</label>
          <input type="text" name="dsc" />
          <button type="button" lay-submit lay-filter="queryTableDevice"
            class="query layui-btn layui-btn-radius layui-btn-primary">
            <span class="search-icon"></span>
            <span class="btn-inner">查询</span>
          </button>
        </form>
      </div>
      <table class="layui-table" id="ProdicobleType"></table>
    </div>
    <div class="footer layui-btn-containner">
      <button class="btn1 layui-btn layui-btn-radius layui-btn-primary">确定</button>
      <button class="btn2 layui-btn layui-btn-radius layui-btn-primary">取消</button>
    </div>
  </div>
</div>
</script> -->

<script>
layui.use(["form", "api", "view", "upload", "laydate", "laytpl", "view", "admin", "layer", "element", "table", "treeSelect",'utill','dtree'], function () {
var api = layui.api;
var form = layui.form;
var view = layui.view;
var upload = layui.upload;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var view = layui.view;
var admin = layui.admin;
var layer = layui.layer;
var $ = layui.$;
var table = layui.table;
var setter = layui.setter;
var element = layui.element;
var utill = layui.utill;
var treeSelect = layui.treeSelect;
var dtree = layui.dtree;
var router = layui.router();
var href = JSON.parse(sessionStorage.getItem('layui-this'));
$(href).addClass('layui-this');

// 获取路由上的参数
var tcApplyFia01 = router.search.tcApplyFia01;
var param = new Object();
param.pageSize = 0;
param.pageNum = 0;
param.fia01 = tcApplyFia01;   //调坑里啦

// 查询列表(ok)
admin.req({
  url: api.host + api.inputFiaFileList_llp,
  data: JSON.stringify(param),
  type: "post",
  contentType: "application/json",
  success: function (data) {
    var data = data.data.list[0];
    var coms = data.tcCoName;

    laytpl($("#template").html()).render(data, function (html) {
      // 把模板添加到页面上
      $("#testDiv").html(html);
      // 渲染单选按钮
      form.render("radio");

      //进行规制校验
      //(1:驱动类型的校验)
      $("#driveType").blur(function () {
        if ($("#driveType").val().length > 20) {
          layer.msg('输入过长,请输入20以内');
          $("#driveType").val("");
        }
      })

      //驱动名称
      $("#driveName").blur(function () {
        if ($("#driveName").val().length > 20) {
          layer.msg('输入过长,请输入20以内');
          $("#driveName").val("");
        }
      })

      //设备IP
      $("#facilityIp").blur(function () {
        if ($("#facilityIp").val().length > 15) {
          layer.msg('输入过长,请输入15以内');
          $("#facilityIp").val("");
        }
      })

      // 资产编码
      $("#CodeMa").blur(function(){
          var text = $("#CodeMa").val();
          var textlen = $("#CodeMa").val().length
          if(textlen>10){
                var lenText=text.substring(0,10);
                $("#CodeMa").val(lenText);
            }
      });

      // 正常生产时长 daijiTime
      $("#timeFange").keyup(function () {
        $(this).val(ChangeNumValue($(this).val()));
      })

      // 待机时长
      $("#daijiTime").keyup(function () {
        $(this).val(ChangeNumValue($(this).val()));
      })

      // 异常时长 errorTime
      $("#errorTime").keyup(function () {
        $(this).val(ChangeNumValue($(this).val()));
      })
      //保养时长
      $("#baoYangTime").keyup(function () {
        $(this).val(ChangeNumValue($(this).val()));
      })
      // 处理的方法(只保留小数点一位)
      function ChangeNumValue(tmpVal) {
        if (tmpVal) {
          var tmpVal = tmpVal.replace(/[^\d\.]/g, '');
          var reg = /^(0|([1-9]\d*))(\.\d{1,1})?$/; //正则验证保留 最多允许后输入两位小数
          if (!reg.test(tmpVal)) {
            tmpVal = tmpVal + "";
            tmpVal = tmpVal.substring(0, tmpVal.indexOf(".") + 2);
            var n = (tmpVal.split('.')).length - 1;
            if (n > 1) {
              tmpVal = tmpVal.substring(0, tmpVal.indexOf("."));
            }
          }
          return tmpVal;
        } else {
          return "";
        }
      }
     //是否联机 tcScadaIsonineT
     form.on('radio(tcScadaIsonineT)', function(data){
         var data = data.value;
         if(data == 'Y'){
           $("#driveType").attr("lay-verify", "required");
           $("#driveName").attr("lay-verify", "required");
           $("#facilityIp").attr("lay-verify", "required");
           $("#driveType").removeAttr("disabled");
           $("#driveName").removeAttr("disabled");
           $("#facilityIp").removeAttr("disabled");
           $(".Falges").css('display','block');
         }else{
           $(".Falges").css('display','none');
           $("#driveType").removeAttr("lay-verify","required");
           $("#driveName").removeAttr("lay-verify","required");
           $("#facilityIp").removeAttr("lay-verify","required");
           $("#driveType").attr("disabled", "disabled");
           $("#driveName").attr("disabled", "disabled");
           $("#facilityIp").attr("disabled", "disabled");
           $("#driveType").val("");
           $("#driveName").val("");
           $("#facilityIp").val("");
         }
   	 }); 
    // 负责部门
    function mydtree(data){
        dtree.renderSelect({
          elem: "#treeSelect",
                width: "100%", // 指定树的宽度
                url: api.host + api.selectCoaltDept,
                headers:{ 
                  'token': layui.sessionData(setter.tableName).token 
                },
                dataType: "json",
                async: false,
                request: {
                  tcReqCoalt: data,
                  token: layui.sessionData(setter.tableName).token 
                },
                select: false,
                method: 'get',
                initLevel: false,
                icon:false,
                accordion: true,
                response: {
                  statusName: "code", //返回标识（必填）
                  statusCode: 0, //返回码（必填）
                  message: "message", 
                  rootName: "data", //根节点名称（必填）
                  title: "gem02",//节点名称（必填）
                  treeId: "gem01",//节点ID（必填）
                  childName: "deptVOS",//子节点名称（默认数据格式必填)
                }
            });
            dtree.on('node("treeSelect")', function(obj){
                var param = dtree.selectVal("treeSelect");
                $('#treeSelect2').val(param.treeSelect_select_nodeId)
            });
      }
      // 账套：(ok)
      admin.req({
        type: "post",
        url: api.host + api.AzpSelectAllAzp_llp,
        success: function (data) {
          var data_llp = data.data;
          if (data.code == 0 || data_llp != "") {
            var datas_llp = "<option></option>";
            data_llp.forEach((item) => {
               if (item.azp02 == coms) {
                 datas_llp += `<option value=${item.azp01} selected>${item.azp02}</option>`;
              }else{
                  datas_llp += `<option value=${item.azp01}>${item.azp02}</option>`;
              }
            });
            $("#zhangTao").html(datas_llp);
            form.render("select", "dataForm");
          }
          var selectOne = $("#zhangTao").val();
          if (selectOne != "" && selectOne != null) {
            $("#ChangFang").removeAttr('disabled');
            $("#selectPerone").removeAttr('disabled');
            $("#ponser").removeAttr('disabled');
            $("#treeSelect").removeAttr('disabled');
            form.render()
          } else {
            $("#ChangFang").attr('disabled', 'disabled');
            $("#selectPerone").attr('disabled','disabled');
            $("#ponser").attr('disabled','disabled');
            $("#treeSelect").attr('disabled', 'disabled');
            form.render()
          }
        form.render("select");
        mydtree(selectOne);
        var llp = '';
        var Object = {
          "codId": selectOne,
          "param": llp
        }
        // 厂房数据请求
        admin.req({
          url: api.host + api.selectFactoryName_llp,
          type: "post",
          dataType: "json",
          contentType: "application/json",
          data: JSON.stringify(Object),
          success: function (res) {
            var responsePa = res.data;
            var code = res.code;
            if (responsePa != null || responsePa != "") {
              var cf_llp = '<option></option>';
              responsePa.forEach((item) => {
                cf_llp += `<option value=${item.TC_FTY_ID}>${item.TC_FTY_NAME}</option>`
              })
              $('#ChangFang').html(cf_llp);
              form.render("select");
            }
          }
        });
         // 保管人
        var param = "";
        var Ponser = {
          id: selectOne,
          param: param
        }
        if(selectOne==null|| selectOne==""){

        }else{
        admin.req({
          type: "post",
          dataType: "json",
          contentType: "application/json",
          url: api.host + api.selectAzpPeople_llp,
          data: JSON.stringify(Ponser),
          success: function (response) {
            var code = response.code;
            var response = response.data;
            if (code == 0 || response != null || response != "") {
              var _res = "<option></option>";
              response.forEach(item => {
                _res += `<option value=${item.TC_HR_GEN01}>${item.GEN02}</option>`;
              });
              $("#selectPerone").html(_res);
              form.render("select");
            }
          }
        });
      }

        // 设备调机人员
        var param = "";
        var Ponser = {
          id: selectOne,
          param: param
        }
        if(selectOne==""){

        }else{
        admin.req({
          type: "post",
          dataType: "json",
          contentType: "application/json",
          url: api.host + api.selectAzpPeople_llp,
          data: JSON.stringify(Ponser),
          success: function (response) {
            var code = response.code;
            var response = response.data;
            if (code == 0 || response != null || response.size != 0) {
              var _res = "<option></option>";
              response.forEach(item => {
                _res += `<option value=${item.TC_HR_GEN01}>${item.GEN02}</option>`;
              });
              $("#ponser").html(_res);
              form.render("select");
            }
          }
        });
      }
      }
      });
      $("body").on("click", function(event){
        $("div[dtree-id][dtree-select]").removeClass("layui-form-selected");
        $("div[dtree-id][dtree-card]").removeClass("dtree-select-show layui-anim layui-anim-upbit");
      });
      // 站别/工序(ok)
      admin.req({
        type: "post",
        url: api.host + api.selectFiaProcId,
        success: function (data) {
          var data = data.data;
          var code = data.code;
          if (data != null || data.size > 0) {
            var _datas = "<option></option>";
            data.forEach(item => {
              _datas += `<option value=${item.tcProcId}>${item.tcProcName}</option>`;
            });
            $("#zhanBie").html(_datas);
            form.render("select");
          }
        }
      });

      // 线别(ok)
      admin.req({
        type: "post",
        url: api.host + api.selectFiaLineId,
        success: function (data) {
          var list = data.data;
          var code = data.code;
          if (code == 0 || list != "" || list != null) {
            var _list = "<option></option>";
            list.forEach(item => {
              _list += `<option value=${item.tcLineId}>${item.tcLineName}</option>`;
            });
            $("#xianBie").html(_list);
            form.render("select");
          }
        }
      });
      utill.showAndHide('.InputButton,#btnSubmit','FiaFileController:insertFiaFile')
      function dis(obj, doc) {
        let val = $(obj).attr('value');
        if (val == null || val == '') {
          $(doc).attr('disabled', 'disabled')
        } else if (val != null || val != '') {
          $(doc).removeAttr('disabled')
        }
      }
      dis('#ChangFang', '#louCeng');
      admin.req({
        url: api.host + api.selectFic01_llp,
        success: function (response_llp) {
          function transferKey(odata) {
            if (odata != "" || odata != null) {
              odata.forEach(obj => {
                obj.title = obj.fic02
                obj.children = obj.child
                delete obj["fic02"]
                delete obj["child"]
                if (obj.children instanceof Array) {
                  transferKey(obj.children)
                }
              })
            }
            return odata
          }
          odataArr = transferKey(response_llp.data)
          treeSelect.render({
            elem: "#typeTree",
            node: odataArr,
            done: (data) => {
              $("#typeTree").val(data.data.title);
              $("#typeTreeTwo").val(data.data.fic01);
            }
          })
        }
      });

      
      $("#ChangFang").attr('disabled', 'disabled');
      $("#selectPerone").attr('disabled', 'disabled');
      $("#ponser").attr('disabled', 'disabled');
      $("#treeSelect").attr('disabled', 'disabled');
      // 厂房
      form.on("select(select)", function (data) {
        var selectOne = $("#zhangTao").val();
        dtree.reload("treeSelect",{  
              request: {
                tcReqCoalt: selectOne,
                token: layui.sessionData(setter.tableName).token 
              }
        });
        if (selectOne != "" && selectOne != null) {
          $("#ChangFang").removeAttr('disabled');
          $("#selectPerone").removeAttr('disabled');
          $("#ponser").removeAttr('disabled');
          $("#treeSelect").removeAttr('disabled');
        } else {
          $("#ChangFang").attr('disabled', 'disabled');
          $("#selectPerone").attr('disabled','disabled');
          $("#ponser").attr('disabled','disabled');
          $("#treeSelect").attr('disabled', 'disabled');
        }
        form.render("select");
        var llp = '';
        var Object = {
          "codId": selectOne,
          "param": llp
        }
        // 厂房数据请求
        admin.req({
          url: api.host + api.selectFactoryName_llp,
          type: "post",
          dataType: "json",
          contentType: "application/json",
          data: JSON.stringify(Object),
          success: function (res) {
            var responsePa = res.data;
            var code = res.code;
            if (responsePa != null || responsePa != "") {
              var cf_llp = '<option></option>';
              responsePa.forEach((item) => {
                cf_llp += `<option value=${item.TC_FTY_ID}>${item.TC_FTY_NAME}</option>`
              })
              $('#ChangFang').html(cf_llp);
              form.render("select");
            }
          }
        });
        // 保管人
        var param = "";
        var Ponser = {
          id: selectOne,
          param: param
        }
        if(selectOne==null|| selectOne==""){
        }else{
        admin.req({
          type: "post",
          dataType: "json",
          contentType: "application/json",
          url: api.host + api.selectAzpPeople_llp,
          data: JSON.stringify(Ponser),
          success: function (response) {
            var code = response.code;
            var response = response.data;
            if (code == 0  || response != "") {
              var _res = "<option></option>";
              response.forEach(item => {
                _res += `<option value=${item.TC_HR_GEN01}>${item.GEN02}</option>`;
              });
              $("#selectPerone").html(_res);
              form.render("select");
            }
          }
        });
      }
        // 设备调机人员
        var param = "";
        var Ponser = {
          id: selectOne,
          param: param
        }
        if(selectOne==""){
        }else{
        admin.req({
          type: "post",
          dataType: "json",
          contentType: "application/json",
          url: api.host + api.selectAzpPeople_llp,
          data: JSON.stringify(Ponser),
          success: function (response) {
            var code = response.code;
            var response = response.data;
            if (code == 0 || response != null || response.size != 0) {
              var _res = "<option></option>";
              response.forEach(item => {
                _res += `<option value=${item.TC_HR_GEN01}>${item.GEN02}</option>`;
              });
              $("#ponser").html(_res);
              form.render("select");
            }
          }
        });
      }
       // 负责部门
        admin.req({
          url: api.host + api.selectCoaltDept,
          data: {
            tcReqCoalt: selectOne
          },
          done: function (res) {
            function transferKey(odata) {
              odata.forEach(obj => {
                obj.title = obj.gem02
                obj.children = obj.deptVOS
                delete obj["gem02"]
                delete obj["deptVOS"]
                if (obj.children instanceof Array) {
                  transferKey(obj.children)
                }
              })
              return odata
            }
            odataArr = transferKey(res.data)
            treeSelect.render({
              elem: "#treeSelect",
              node: odataArr,
              done: (data) => {
                $("#treeSelect").empty();
                $("#treeSelect").html('')
                $("#treeSelect").val(data.data.title);
                $("#treeSelect2").val(data.data.gem01);
              }
            })
          }
        });
      });

       // 楼层
        form.on("select(select2)", function (data) {
          let val = data.value;
          if (val != null && val != '') {
             $("#louCeng").removeAttr('disabled');
            dis('#ChangFang', '#louCeng');
            var cfs_llp = $("#ChangFang").val();
            var Objects = {
              "id": cfs_llp
            }
            admin.req({
              url: api.host + api.selectDevFactoryName_llp,
              type: "post",
              dataType: "json",
              contentType: "application/json",
              data: JSON.stringify(Objects),
              success: function (res) {
                var footers_llp = res.data;
                if (footers_llp != null || footers_llp != "") {
                  var _footer = '<option value=""></option>';
                  footers_llp.forEach((item) => {
                    _footer += `<option value=${item.TC_FLR_ID}>${item.TC_FLR_NAME}</option>`
                  })
                  $('#louCeng').html(_footer);
                  form.render("select");
                }
              }
            });
          } else if (val == null || val == '') {
            dis('#ChangFang', '#louCeng');
          }
        })
      //文件上传功能
      var arr = [];
      var index = 0;
      //执行实例
      var uploadInst = upload.render({
        elem: "#id_upload",
        url: api.host + api.upload_llp,
        multiple: true,
        size: 100000000,
        method: "post",
        accept: "images",
        headers: { 'token': layui.sessionData(setter.tableName).token },
        done: function (res) {
          arr.push({
            img: res.data[0],
            index: ++index
          });
          var i = 1;
          $("#path").append(
            "<li Style='color: red;position:relative'><img class='closeBtn' style='position:absolute;top:-4px;right:0' src='./../../../dist/img/close.png'><img class='imagesUpload' src= '" + api.imghost + "/" +
            res.data[0] +
            "' style='width: 40px; height: 40px;margin:2px'/><input class='path' value=" +
            res.data[0] +
            " style='display:none' /></li>"
          );
          i++;
          // 点击关闭图片和关闭按钮取消
          $(".closeBtn").click(function () {
            var _llpImag = $(this).next();
            let imghost = api.imghost + "\/";
            var imgpath = _llpImag.attr('src');
            // var obj = {}
            for (let i = 0; i < arr.length; i++) {
              if (arr[i].img == imgpath) {
                arr.splice(i, 1);
              }
            }
            _llpImag.remove();
            $(this).remove();
          })
        }
      });
      var allData = {
        details: [],
        type: []
      }
      // 机台能力弹出层
      // $("#alertChooseOne").click(function () {
      //   layer.open({
      //           type: 1,
      //           title: false,
      //           area: ["680px", "536px"],
      //           fixed: true,
      //           shadeClose: true,
      //           closeBtn: 0,
      //           content: $("#addDeviceTpl").html(),
      //           success: alertEvent.addDevice
      //      });
      // });
      // 可生产产品类型
      // $("#alertChooseTwo").click(function () {
      //   layer.open({
      //           type: 1,
      //           title: false,
      //           area: ["680px", "536px"],
      //           fixed: true,
      //           shadeClose: true,
      //           closeBtn: 0,
      //           content: $("#addDeviceTpl2").html(),
      //           success: alertEvent.addDevice2
      //      });
      // });
      // 
      // 时间格式组件
      laydate.render({
        elem: "#qiDongDay",
        type: 'datetime',
        trigger: 'click',
        btns: ['confirm', 'clear']
      });
      laydate.render({
        elem: "#fixData",
        type: 'datetime',
        trigger: 'click',
        btns: ['confirm', 'clear']
      });
      laydate.render({
        elem: "#YanShouData",
        type: 'datetime',
        trigger: 'click',
        btns: ['confirm', 'clear']
      });
      laydate.render({
        elem: "#buyData",
        type: 'datetime',
        trigger: 'click',
        btns: ['confirm', 'clear']
      });
      //  表单提交
      form.on('submit(formSubmlitButton)', function (data) {
        var field = data.field;
        var fia01 = field.fia01;                          //设备编号
        var fiaplant = field.fiaplant;                    //账套
        var fia011 = field.fia011;                        //资产编号
        var fia02 = field.fia02;                          //设备名称
        var tcDevIsDisable = field.tcDevIsDisable;        //是否启用
        var fia03 = field.fia03;                          //设备类型
        var fia19 = field.fia19;                          //启动日期
        var fia20 = field.fia20;                          //保修日期
        var tcDevChkdate = field.tcDevChkdate;            //验收日期
        var fia05 = field.fia05;                          //设备型号
        var fia04 = field.fia04;                          //设备系列
        var fiaacti = field.fiaacti;                      //设备状态
        var fia09 = field.fia09;                          //供应商
        var fia11 = field.fia11;                          //负责部门
        var fia10 = field.fia10;                          //保管人
        // var tcCapCapId = field.tcCapCapId;                //机台能力
        var tcDevPrecision = field.tcDevPrecision;        //精度
        // var tcProdProdId = field.tcProdProdId;            //可生产产品类型
        var tcScadaProdtime = field.tcScadaProdtime;      //正常生产时间
        var tcScadaStdbytime = field.tcScadaStdbytime;    //待机时长
        var tcScadaExcptime = field.tcScadaExcptime;      //异常时长
        var fia25 = field.fia25;                          //安全说明
        var fiauser = field.fiauser;                      //设备调机人员
        var fia14 = field.fia14;                          //厂房
        var fia15 = field.fia15;                          //楼层
        var fia16 = field.fia16;                          //站别和工序
        var fia17 = field.fia17;                          //线别
        var fia18 = field.fia18;                          //购买日期
        var tcScadaMainttime = field.tcScadaMainttime;    //维修时长 
        var tcScadaProduction = field.tcScadaProduction;  //产量     
        var tcScadaIsonine = field.tcScadaIsonine;        //是否联机   
        var tcScadaDrvtype = field.tcScadaDrvtype;        //驱动类型    
        var tcScadaDrvname = field.tcScadaDrvname;        //驱动名称
        var tcScadaIpaddress = field.tcScadaIpaddress;    //设备IP
        var fia22 = field.fia22;                          //备注
        var arrs = [];
        var arrs2 = [];
        // 图片
        var paths = [];
        // 机台能力
        allData.details.map(function (item) {
          arrs.push(item.TC_CAP_ID);
        })

        // 可生产产品类型
        allData.type.map(function (item) {
          arrs2.push(item.TC_PROD_ID);
        })

        arr.forEach(function (item) {
          paths.push(item.img);
        })
        var obj = {
          tcFilePath: paths,
          fia01: fia01,
          fiaplant: fiaplant,
          tcDevIsDisable:tcDevIsDisable,
          fia011: fia011,
          fia02: fia02,
          fia03: fia03,
          fia19: fia19,
          fia20: fia20,
          tcDevChkdate: tcDevChkdate,
          fia05: fia05,
          fia04: fia04,
          fiaacti: fiaacti,
          fia09: fia09,
          fia11: fia11,
          fia10: fia10,
          // tcCapCapId: arrs,
          tcDevPrecision: tcDevPrecision,
          // tcProdProdId: arrs2,
          tcScadaProdtime: tcScadaProdtime,
          tcScadaStdbytime: tcScadaStdbytime,
          tcScadaExcptime: tcScadaExcptime,
          fia25: fia25,
          fiauser: fiauser,
          fia14: fia14,
          fia15: fia15,
          fia16: fia16,
          fia17: fia17,
          fia18: fia18,
          tcScadaMainttime: tcScadaMainttime,
          tcScadaProduction: tcScadaProduction,
          tcScadaIsonine: tcScadaIsonine,
          tcScadaDrvtype: tcScadaDrvtype,
          tcScadaDrvname: tcScadaDrvname,
          tcScadaIpaddress: tcScadaIpaddress,
          fia22: fia22
        }
        // 设备录入
        admin.req({
          type: "post",
          dataType: "json",
          contentType: "application/json",
          url: api.host + api.insertFiaFile,
          data: JSON.stringify(obj),
          success: function (data) {
            var code = data.code;
            if (code == 0) {
              layer.msg(data.message);
              location.hash = '/home/cash'
            } else {
              layer.msg(data.message);
            }
          }
        });
      });
      var alertEvent = {
            // addDevice: function (layero, index) {
            //    table.render(
            //     $.extend({}, utill.tableOpts(), {
            //     elem: "#MachineCapacityTable",
            //     id: "#MachineCapacityTable",
            //     height: 300,
            //     toolbar: "",
            //     url: api.host + api.selectCapacitys_llp,
            //     type: 'post',
            //     cols: [
            //         [
            //         { fixed: "left", type: "checkbox" },
            //         { field: "TC_CAP_CODE", title: "机台能力编号" },
            //         { field: "TC_CAP_NAME", title: "机台能力名称" },
            //         { field: "TC_CAP_DSC", title: "机台能力描述" }
            //         ]
            //     ]
            //     })
            //    );
            //  $('.leon-style-alert .con1').click(function(){
            //    $('.con2').toggle();
            //  })
            // //  条件查询
            // form.on("submit(queryTableDevice)", function (data) {
            //     var allData = data.field;
            //     table.reload("#MachineCapacityTable", {
            //     where: allData
            //     });
            //     return false;
            //  });
            // //确定按钮
            // $(".btn1").click(function(){
            //     var checkStatus = table.checkStatus('#MachineCapacityTable');
            //     if (checkStatus.data.length == 0) {
            //         parent.layer.msg('至少选择一条');
            //         return;
            //     }
            //     var CheckBox = [];
            //     var CheckBoxs = [];
            //     for (var i = 0; i < checkStatus.data.length; i++) {
            //         CheckBox.push(checkStatus.data[i].TC_CAP_NAME);
            //         CheckBoxs.push(checkStatus.data[i].TC_CAP_ID);
            //     }
            //     if (allData.details.length > 0) {
            //         for (var i = 0; i < allData.details.length; i++) {
            //             for (var j = 0; j < checkStatus.data.length; j++) {
            //                 if (checkStatus.data[j].TC_CAP_ID == allData.details[i].TC_CAP_ID) {
            //                     checkStatus.data.splice(j, 1)
            //                     j = j - 1;
            //                 }
            //             }
            //         }
            //     }
            //     checkStatus.data.map(function (dataItem, dataIndex) {
            //         var modeTPL = `<span class="mode">${dataItem.TC_CAP_NAME}<i class="layui-icon layui-icon-close deleteMode"></i></span>`;
            //         $('#detailBox').append(modeTPL)
            //         allData.details.push(dataItem)
            //     })
            //     $('#detailBox').on('click', '.deleteMode', function (e) {
            //         var $target = $(e.target),
            //             cur = $target.parents('.mode'),
            //             idx = $target.parents('.mode').index();
            //         allData.details.splice(idx, 1);
            //         cur.remove();
            //     })
            //     // 成功后关闭
            //     layer.close(index);
            // })
            // // 取消按钮
            // $(".btn2").click(function(){
            //    layer.close(index);
            // })
            // },
            // addDevice2:function(layero, index){
            //   table.render(
            //     $.extend({}, utill.tableOpts(), {
            //     elem: "#ProdicobleType",
            //     id: "#ProdicobleType",
            //     height: 300,
            //     toolbar: "",
            //     url: api.host + api.selectProducts_llp,
            //     type: 'post',
            //     cols: [
            //         [
            //         { fixed: "left", type: "checkbox" },
            //         { field: "TC_PROD_CODE", title: "产品类型编号" },
            //         { field: "TC_PROD_NAME", title: "产品类型名称" },
            //         { field: "TC_PROD_DSC", title: "产品类型描述" }
            //         ]
            //     ]
            //     })
            //    );
            //    //查询显示和隐藏
            //    $('.leon-style-alert .con1').click(function(){
            //       $('.con2').toggle();
            //    })
            //    //高查
            //    form.on("submit(queryTableDevice)", function (data) {
            //         var allData = data.field;
            //         table.reload("#ProdicobleType", {
            //         where: allData
            //         });
            //         return false;
            //    })
            //    //点击确定按钮
            //    $(".btn1").click(function(){
            //     var checkStatus = table.checkStatus('#ProdicobleType');
            //         if (checkStatus.data.length == 0) {
            //             parent.layer.msg('至少选择一条');
            //             return;
            //         }
            //         var CheckBox2 = [];
            //         var CheckBox2s = [];
            //         for (var i = 0; i < checkStatus.data.length; i++) {
            //             CheckBox2.push(checkStatus.data[i].TC_PROD_ID);
            //             CheckBox2s.push(checkStatus.data[i].TC_PROD_NAME);
            //         }
            //         if (allData.type.length > 0) {
            //             for (var i = 0; i < allData.type.length; i++) {
            //                 for (var j = 0; j < checkStatus.data.length; j++) {
            //                     if (checkStatus.data[j].TC_PROD_ID == allData.type[i].TC_PROD_ID) {
            //                         checkStatus.data.splice(j, 1)
            //                         j = j - 1;
            //                     }
            //                 }
            //             }
            //         }
            //         checkStatus.data.map(function (dataItem, dataIndex) {
            //             var modeTPL = `<span class="mode">${dataItem.TC_PROD_NAME}<i class="layui-icon layui-icon-close deleteMode"></i></span>`;
            //             $('#typeBox').append(modeTPL)
            //             allData.type.push(dataItem)
            //         })
            //         $('#typeBox').on('click', '.deleteMode', function (e) {
            //             var $target = $(e.target),
            //                 cur = $target.parents('.mode'),
            //                 idx = $target.parents('.mode').index();
            //             allData.type.splice(idx, 1);
            //             cur.remove();
            //         })
            //         // 成功后关闭
            //         layer.close(index);
            //    })
            //    $(".btn2").click(function(){
            //       layer.close(index);
            //    })
            // }
        }
      // 取消按钮回到前面的页面
      $('.cancel-btn').attr('lay-href', 'home/cash');
    });
  }
});
// 设备信息录入
$(".InputButton").click(function () {
  location.hash = '/home/my_home/information';
  var href = '[data-jump="home/my_home/information"]';
  sessionStorage.setItem('layui-this', JSON.stringify(href));
})
}
);
</script>